<?php



require_once "php/config.php";
require_once "geshi/geshi.php";

$url = $_REQUEST['url'];

$info = getSvnFileInfo($url);
$old = $_REQUEST['old'];
$new = $_REQUEST['new'];

#$command = "svn diff --old={$url}@{$old} --new={$url}@{$new} {$svnAuth}";
#$diff = shellCommand($command);
#$diff = implode($diff);
#$diff = utf8_encode($diff);


$oldContent = implode(shellCommand("svn cat {$url} {$svnAuth} --revision {$old}"));
$newContent = implode(shellCommand("svn cat {$url} {$svnAuth} --revision {$new}"));

$oldFile = newTempFile($oldContent);
$newFile = newTempFile($newContent);

#$command = "diff -cEbBwa {$oldFile} {$newFile}";
$command = "diff -uEbBwa {$oldFile} {$newFile}";
#$command = "sdiff  {$oldFile} {$newFile}";

$diff = shellCommand($command);
$diff = implode($diff);
$diff = utf8_encode($diff);

$diff = str_replace($oldFile,$info['name'].' r'.$old,$diff);
$diff = str_replace($newFile,$info['name'].' r'.$new,$diff);


$diff = $diff ? $diff : 'No differences found.';

#$c1 = implode($c1);
#$c2 = implode($c2);
#$file1 = newTempFile($c1);
#$file2 = newTempFile($c2);



$geshi = new GeSHi($diff,'diff');
$geshi->set_line_style('color: #777777;', 'color: #777777;');
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); 
$geshi->set_tab_width(4);
$geshi->set_header_type(GESHI_HEADER_NONE);
echo $geshi->parse_code();




